#include "StdAfx.h"
#include "LogSystem.h"

LogSystem::LogSystem(void)
{
}

LogSystem::~LogSystem(void)
{
	_List.clear();
}

shared_ptr<LogView> LogSystem::CreateLogView(LogView::LOGVIEWDESC * desc)
{
	shared_ptr<LogView> logview(new LogView);
	Attach(logview);
	logview->Init(desc);
	return logview;
}

void LogSystem::Attach(shared_ptr<LogView> logview)
{
	_List.push_back(logview);
}

void LogSystem::DestroyLogView(string logviewname)
{
	for (LogViewList::iterator it = _List.begin(); it != _List.end(); it++)
	{
		shared_ptr<LogView> logview = *it;
		string lookup(logview->GetDesc().name);
		if (lookup.compare(logviewname) == 0)
		{
			_List.erase(it);
			return;
		}
	}
}

HRESULT LogSystem::OnInitSingleton(void)
{
	HRESULT hr;
	StdLog * log = new StdLog();
	CHECKHR(log->ReadConfiguration());
	return log->Create();
}

void LogSystem::OnUninitSingleton(void)
{
}

